﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using br.com.SistemaChamados.Enum;
using System.Data;
using br.com.SistemaChamados.Model;

namespace br.com.SistemaChamados.DAO
{
    public class CallStatusDAO
    {
        private static string SQL_INSERT_CALLSTATUS = " INSERT INTO TBL_CALLSTATUS (TBL_CALLSTATUSDESCRIPTION) VALUES (@callstatusdescription) ";

        public EnumGenericState InsertCallStatus(CallStatus callStatus)
        {
            EnumGenericState resultCallStatus = EnumGenericState.GENERIC_STATE_UNKNOW;
            IDbConnection conn = null;
            IDbCommand command = null;
            try
            {
                conn = Mapped.Connection();
                command = Mapped.Command(SQL_INSERT_CALLSTATUS, conn);
                command.Parameters.Add(Mapped.Parameter("@callstatusdescription", callStatus.Description));
                command.ExecuteNonQuery();
                resultCallStatus = EnumGenericState.GENERIC_STATE_SUCCESS;
            }
            catch (Exception ex)
            {
                resultCallStatus = EnumGenericState.GENERIC_STATE_FAILED;
                throw ex;
            }
            finally
            {
                if (conn != null) conn.Close();
            }

            return resultCallStatus;

        }
        public CallStatusDAO()
        {
            //
            // TODO: Add constructor logic here
            //
        }
    }
}